package com.mybase.app.system;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import com.mybase.app.UI.WidgetActivity;
import com.mybase.app.entity.MyMenuItem;
import com.mybase.app.extend.MapActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by happy_000 on 2014/12/5.
 * 获取系统各种参数 属性 状态
 */
public class SystemHomeActivity extends ListActivity {
    private ListAdapter mAdapter;
    List<MyMenuItem> itemList=new ArrayList<MyMenuItem>(0);
    private List<String> list=new ArrayList<String>(0);

    public  List<MyMenuItem> getRootMenuItems() {
        List<MyMenuItem> list=new ArrayList<MyMenuItem>(0);
        MyMenuItem menuItem1 = new MyMenuItem();
        menuItem1.setName(" 设备信息");
        menuItem1.setActivity(DeviceActivity.class);
        list.add(menuItem1);
        //**********************************************************
//        MyMenuItem menuItem2 = new MyMenuItem();
//        menuItem2.setName("Widget 控件");
//        menuItem2.setActivity(WidgetActivity.class);
//        list.add(menuItem2);
//        //**********************************************************
//        MyMenuItem menuItem3 = new MyMenuItem();
//        menuItem3.setName("resource资源文件");
//        //  menuItem3.setActivity(ResetPasswdActivity.class);
//        list.add(menuItem3);
//        //**********************************************************
//        MyMenuItem menuItem4 = new MyMenuItem();
//        menuItem4.setName("map");
//        menuItem4.setActivity(MapActivity.class);
//        list.add(menuItem4);
        //**********************************************************
        return list;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        itemList= getRootMenuItems();
        initdatas();
        mAdapter=new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1,list);
        setListAdapter(mAdapter);
    }
    private  void initdatas(){
        for (MyMenuItem myMenuItem : itemList) {
            list.add(myMenuItem.getName());
        }
    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        MyMenuItem myMenuItem=itemList.get(position);
        Intent intent=new Intent(this,myMenuItem.getActivity());
        startActivityForResult(intent,RESULT_OK);
    }
}
